package tools;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import biblioteque.Bibliotheque;
import biblioteque.Mot;

public class Tools {

	public static void afficher(HashMap<String,Mot> myHashMap)
	{
		
		for (Map.Entry<String,Mot> e : myHashMap.entrySet()){
			System.out.println(e.getKey() + " : " + e.getValue());
		}
	}
	
	public static void enregistrer(Bibliotheque b)
	{
		try {
			FileOutputStream fichier = new FileOutputStream("bibliotheque.ser");
			ObjectOutputStream oos = new ObjectOutputStream(fichier);
			oos.writeObject(b);
			oos.flush();
			oos.close();
			}
			catch (java.io.IOException e) {
			e.printStackTrace();
			}

		}
	public static Bibliotheque lire(){
		Bibliotheque b = null;
		try {
			FileInputStream fichier = new FileInputStream("bibliotheque.ser");
			ObjectInputStream ois = new ObjectInputStream(fichier);
			b = (Bibliotheque) ois.readObject();
			}
			catch (java.io.IOException e) {
			e.printStackTrace();
			}
			catch (ClassNotFoundException e) {
			e.printStackTrace();
			}
		
		return b;
		
	}
		
}